/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hps.model;

import java.io.Serializable;

/**
 *
 * @author $Author: NIKE3500 $
 * @version $Revision: 94 $
 * @date $Date: 2013-01-22 21:08:20 +0000 (Tue, 22 Jan 2013) $
 */
public class Point implements Serializable
{

    private int x;
    private int y;

    public Point()
    {
    }

    public Point(int x, int y)
    {
        this.x = x;
        this.y = y;
    }

    public int getX()
    {
        return this.x;
    }

    public int getY()
    {
        return this.y;
    }

    public void setX(int x)
    {
        this.x = x;
    }

    public void setY(int y)
    {
        this.y = y;
    }

    /**
     *
     * @param p Object of Type Point
     * @return true, if p equals this
     */
    @Override
    public boolean equals(Object p)
    {
        if (p == null)
        {
            return false;
        }
        if (!(p instanceof Point))
        {
            return false;
        }
        if (!(x == ((Point) p).getX() && y == ((Point) p).getY()))
        {
            return false;
        }
        return true;

    }

    /**
     * Gibt den Abstand zu einem Punkt zurueck
     *
     * @param p Punkt, zu dem der Abstand errechnet werden soll
     * @return Abstand zum uebergebenen Punkt
     */
    public double distance(Point p)
    {
        return Math.sqrt(x * x + y * y);
    }

    @Override
    public int hashCode()
    {
        int hash = 7;
        hash = 71 * hash + this.x;
        hash = 71 * hash + this.y;
        return hash;
    }

    @Override
    public Point clone()
    {
        return new Point(x, y);
    }

    @Override
    public String toString()
    {
        return "(" + x + "/" + y + ")";
    }
}
